<script>
		 export default { 
			onLaunch(res) {
				// 获取推荐码
				if(res.query.scene) uni.setStorageSync('parent_openid',res.query.scene);
			},
			async onShow() {
				let _this = this
				// 检测是否有新版本需要更新
				const updateManager = uni.getUpdateManager();
				
				updateManager.onCheckForUpdate(function (res) {
				  // 请求完新版本信息的回调
				  if(res.hasUpdate) updateManager.onUpdateReady(function (res) {
				  uni.showModal({
				    title: '更新提示',
				    content: '新版本已上线啦！为了给你提供更优质的服务！请及时跟新！',
				    success(res) {
				      if (res.confirm) {
				        // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
				        updateManager.applyUpdate();
				      }
				    }
				  });
				
				});
				});
				updateManager.onUpdateFailed(function (res) {
					uni.showToast({
						title:"版本更新失败！",
						icon:"none"
					})
				});
				try{
					if(getApp().globalData.type != 1) {
					let req = uni.getStorageSync('cleaningData');
					let token = req?req.token?req.token:'':'';
					if(token != '') {
						let wz = await uni.getLocation()
						if(wz[0] == null && wz[1].longitude != null && wz[1].longitude != undefined && wz[1].longitude != '') {
							uni.setStorageSync('longitude', wz[1].longitude);
							uni.setStorageSync('latitude', wz[1].latitude);
							getApp().globalData.type = 2
							let aas = await this.$http.post('/index/Login/update_userinfo',{user_longitude:wz[1].longitude,user_latitude:wz[1].latitude},{header:{token}})
						}
						}
					
					}
					let rep = await this.$http.get('/index/Communal/config_data',{config_id:3})
					uni.setStorageSync('wechat_share_title', rep.wechat_share_title.value);
					uni.setStorageSync('wechat_code', rep.wechat_code.value);
					uni.setStorageSync('wechat_share_image', rep.wechat_share_image.value);
				}catch(e){
					if(e.errno && e.errno == 103) return uni.showModal({
						title:"提示",
						content:"你的位置信息将用于提供显示你距目标位置的距离",
						showCancel:true,
						cancelText:'取消',
						cancelColor:"#000000",
						confirmColor:"#3cc51f",
						confirmText:"确定",
						success(res) {
							console.log('2')
							if(res.confirm) {
								console.log('3')
								uni.openSetting({
								success(res) {
									console.log('获取授权信息',res.authSetting)
								},
								fail(e) {
									console.log('获取设置失败',e)
								}
								});
							}else if(res.cancel) {
								uni.showToast({
									title:"需要授权位置信息才可认证！",
									icon:"none"
								})
							}
						}
					})
					else uni.showToast({
						title:e.errMsg,
						icon:"none"
					})
				}
				
			},
			
			onHide: function() {
			},
			globalData:{
				url:"https://www.zhuoxianrenli.cn/",
				imgScr:'https://www.zhuoxianrenli.cn/static/index/kefangshao/',
				// url:"http://baseadmin.ixiaoquan.live/",
				// imgScr:'http://baseadmin.ixiaoquan.live/static/index/kefangshao/',
				type:1,
			},
		}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni_modules/uni-scss/index.scss';
	/* #ifndef APP-NVUE */
	@import '@/static/customicons.css';
	@import '@/static/iconfont.css';
	// 设置整个项目的背景色
	view{
		box-sizing: border-box;
	}
	page {
		background-color: #f5f7fd;
		// background-color: #000000;
		.example-info {
			font-size: 28rpx;
			color: #333;
			padding: 20rpx;
		}
		.uni-card {
			.uni-card__header {
				padding: 20rpx 0;
				margin-bottom: 20rpx;
				border-color: #ededed;
				.uni-card__header-content {
					.uni-card__header-content-title {
						font-size: 30rpx;
						font-weight: 600;
						color: #000000;
					}
				}
			}
		}
		.uni-load-more__text {
			font-size: 28rpx;
			font-weight: 500;
		}
		.but::after {
			display: none;
		}
		.uni-easyinput, .input {
			.uni-easyinput__content-textarea,.uni-easyinput__content-input,.uni-combox__input {
				font-size: 28rpx;
				font-weight: 500;
				color: #000000;
			}
			.uni-easyinput__placeholder-class,.uni-combox__input-plac,.placeholder-class {
				font-size: 28rpx;
				font-weight: 500;
				color: rgba($color: #000000, $alpha: 0.3);
			}
		}
		
		.uni-forms-item__label {
			.label-text {
				font-size: 28rpx;
				font-weight: 500;
			}
		}
	}
	/* #endif */
</style>
